

************************************************************************
************************************************************************
*** TABLE 1  ***********************************************************
************************************************************************
************************************************************************


set more off
use  "${data}Panel_quarterly.dta", replace

keep if analysis_sample==1

* Get invidiual covariates

merge n:1 spell_identifier using  "${data}Cross_section.dta", keepusing($X_ind  mean_Application_month mean_explained_monthly_w)
keep if _merge==3
drop _merge

* Restrict sample to period in which the first job of each spell is found

keep if Quarter_FirstJob>0

* Labels:

label variable quarter_to_exhaustion_plus1 "$ T-1$"
label variable quarter_to_exhaustion_plus2 "$ T-2$"
label variable quarter_to_exhaustion_plus3 "$ T-3$"
label variable quarter_to_exhaustion_plus4 "$ T-4$"
label variable quarter_to_exhaustion_0 "$ T$"
label variable quarter_to_exhaustion_minus1 "$ T+1$"
label variable quarter_to_exhaustion_minus2 "$ T+2$"
label variable quarter_to_exhaustion_minus3 "$ T+3$"
label variable quarter_to_exhaustion_minus4 "$ T+4$"

* Rgeressions:

set more off

xi : logit Job_Found_Online ${MainQTE} ${OtherQTE} 	i.PBD  ,   	  vce(robust)
		estadd local SpellTimeFE "No"
		estadd local PBDFE "Yes"
		estadd local Covariates "No"
est store m1

xi : logit Job_Found_Online ${MainQTE} ${OtherQTE} 	 ${X_ind} mean_Application_month mean_explained_monthly_w	i.PBD  ,   	  vce(robust)
		estadd local SpellTimeFE "No"
		estadd local PBDFE "Yes"
		estadd local Covariates "Yes"
est store m2

xi : logit Job_Found_Online ${MainQTE} ${OtherQTE}  ${SpellTimeFE}	i.PBD  ,   	  vce(robust)
		estadd local SpellTimeFE "Yes"
		estadd local PBDFE "Yes"
		estadd local Covariates "No"
est store m3

xi : logit Job_Found_Online ${MainQTE} ${OtherQTE}  ${SpellTimeFE}	 ${X_ind} mean_Application_month mean_explained_monthly_w	i.PBD  ,   	  vce(robust)
		estadd local SpellTimeFE "Yes"
		estadd local PBDFE "Yes"
		estadd local Covariates "Yes"
est store m4


estout m1 m2 m3 m4 using "Table1",  style(tex) transform(exp(@)-1 exp(@))  keep(${MainQTE})  ///
  label  cells( b(star fmt(3)) se(par fmt(3)) ) starlevels( * 0.10 ** 0.05 *** 0.010)  ///
  stats( PBDFE  Covariates SpellTimeFE N, labels(   "PBD-group FE" "Individual covariates" "Spell time FE"  "No. of Obs") fmt(%9.3f %9.3f %9.3f %9.0fc )) ///
  replace title("Test for search channel substitution around benefits exhaustion") mlabels(none) numbers 

estout m1 m2 m3 m4 using "Table1.xls",   transform(exp(@)-1 exp(@))  keep(${MainQTE}) ///
 label cells( b(star fmt(3)) se( fmt(3))  )  starlevels( * 0.10 ** 0.05 *** 0.010)  ///
 varlabel(quarter_to_exhaustion_plus3 "T-3" quarter_to_exhaustion_plus2 "T-2"  quarter_to_exhaustion_plus1 "T-1"  quarter_to_exhaustion_0 "T" quarter_to_exhaustion_minus1 "T+1" quarter_to_exhaustion_minus2 "T+2" quarter_to_exhaustion_minus3 "T+3" quarter_to_exhaustion_minus4 "T+4") ///
  stats( PBDFE  Covariates SpellTimeFE N, labels(   "PBD-group FE" "Individual covariates" "Spell time FE"  "No. of Obs") fmt(%9.3f %9.3f %9.3f %9.0fc )) ///
 replace  title("Test for search channel substitution around benefits exhaustion")   mlabels("1" "2" "3" "4") 
 

 
